package com.wym.exampleproject.distributedzookeeperlock.config;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryNTimes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Configuration
public class ZkConfiguration {

    @Autowired
    private ZkConfigInfo zkConfigInfo;

    @PostConstruct
    @Bean
    public CuratorFramework curatorFramework() {
        System.out.println("1231232132131");
        return CuratorFrameworkFactory.newClient(
                zkConfigInfo.getConnectString(),
                zkConfigInfo.getSessionTimeoutMs(),
                zkConfigInfo.getConnectionTimeoutMs(),
                new RetryNTimes(zkConfigInfo.getRetryCount(), zkConfigInfo.getElapsedTimeMs()));


    }
}
